# Locate Antlr
#
# Author: pepone.onrez@gmail.com
# License: GPL-v3
#
# This cmake script searchs for the Antlr c++ package.
# Note that i only test it on gentoo/linux you must need add other paths
# for other Os. Also we must need same test for guest that we have the required version.
#
# start with 'not found'
#
# If you has any suggestions fell free to post in the user group
# http://groups.google.com/group/ydra
#

SET( ANTLR_FOUND 0 CACHE BOOL "Do we have Antlr?" )

FIND_PATH(ANTLR_INCLUDE_DIR antlr/config.hpp /usr/include /opt/antlr/include)

FIND_PATH(ANTLR_STATIC_LIB_DIR libantlr.a /usr/lib /opt/antlr/lib)

FIND_PROGRAM(ANTLR_COMPILER antlr /usr/bin /opt/antlr/bin)

IF ( ANTLR_INCLUDE_DIR)
    SET( ANTLR_FOUND 1 CACHE BOOL "Do we have Antlr?" FORCE )
    SET( ANTLR_INCLUDES ${ANTLR_INCLUDE_DIR} )
ENDIF( ANTLR_INCLUDE_DIR )

IF(ANTLR_FOUND)
    IF(NOT ANTLR_STATIC_LIB_DIR)
        SET( ANTLR_FOUND 1 CACHE BOOL "Do we have Antlr?" FORCE )
    ELSE
        SET( ANTLR_STATIC_LIB ${ANTLR_STATIC_LIB_DIR}/libantlr.a )
    ENDIF(NOT ANTLR_STATIC_LIB_DIR)
ENDIF(ANTLR_FOUND)

IF(ANTLR_FOUND)
    IF(NOT ANTLR_COMPILER)
        SET( ANTLR_FOUND 0 CACHE BOOL "Do we have Antlr?" FORCE )
    ELSE
        SET( ANTLR_COMMAND ${ANTLR_COMPILER} )
    ENDIF(NOT ANTLR_COMPILER)
ENDIF(ANTLR_FOUND)